{template 'pc_header'}
<link rel="stylesheet" type="text/css" href="{MODULE_URL}template/mobile/app/css/screen_lottory_free.css">
<link rel="stylesheet" type="text/css" href="{MODULE_URL}template/mobile/app/css/linewell_qd.css">
<script src="{MODULE_URL}template/mobile/app/js/qdbase.js?20154223" type="text/javascript" charset="utf-8"></script>
<script src="{MODULE_URL}template/mobile/app/js/screen_qd.js" type="text/javascript" charset="utf-8"></script>
</head>
<body class="FUN WALL" {if !empty($basic_config['bg_vedio'])}data-vide-bg="{php echo tomedia($basic_config['bg_vedio'])}"{/if}>
{template 'top_panel'}
<div class="Panel Lottery" style="display: block; opacity: 1;">
  <div class="tuchu ">
    <div class="tuchug">
      <img src="{MODULE_URL}template/mobile/app/images/icon/bbb.png"></div>
    <div class="tuchuk">
      <img class="tx" id="qdtx" src="http://wx.qlogo.cn/mmopen/ctSue0WnfibLR4ponCgXLv4G9Y43YFEXv5UboZuvHbvwkz6QXEYvw4RyuktMxhicq22efPTnwhPRhT67FIia2dmKDlIb4falNbN/132">
      <p class="pm">第
        <span class="red" id="qdnums">0</span>位签到</p>
      <p class="xm" id="qdname">官方签到女神</p></div>
  </div>
  <div class="qiandao" id="ddd" style="display: none;">
    <ul id="divDetail">
      {loop $qds $key $row}
      <li id="dh{php echo $key+1}">
        <img class="qiaodaotx" id="hd{php echo $key+1}" src="{$row['avatar']}">
        <p class="qiaodaoxm" id="nc{php echo $key+1}">{$row['nick_name']}</p>
        <p id="qd{php echo $key+1}" class="qiaodaopm">{php echo $key+1}</p>
      </li>
      {/loop}
    </ul>
  </div>
  <script>
      function senddh(n) {
          var count2 = $('#divDetail li').size();//0
          if (n <= count2) {//无人签到
              $("#dh" + n).addClass('qiaodaosf');
              var div = document.getElementById('divDetail');
              document.getElementById('ddd').scrollTop = div.scrollHeight;
              n = n + 1;
              setTimeout("senddh(" + n + ")", 500);
          } else {
              try{
                  setTimeout("getjson(" + {$qd_maxid} + ")", 1000);
              }catch(e){
                  console.log("出现异常！");
                  //setTimeout("getjson(" + {$qd_maxid} + ")", 1000);
              }

          }
      }

      function senddh2(n) {
          if (n > 0 && window.ssss != 0) {
              $("#dh" + n).removeClass('qiaodaosf');
              var div = document.getElementById('divDetail');
              document.getElementById('ddd').scrollTop = div.scrollHeight;
              n = n - 1;
              setTimeout("senddh2(" + n + ")", 500);
          } else {
              setTimeout("senddh(" + n + ")", 1000);
          }
      }

      var mid;
      var b;
      var ssss = 0;
      var ii = {$qd_nums};
      function getjson(v) {
          $(".tuchu").removeClass('view');

          $.ajax({
              async: true,
              url : Path_url('new_qd'),
              dataType:"JSON",
              type:"GET",
              data:{
                  rid: scene_id,
                  mid: v
              },
              success:function(result){
                  var b = result.mid;//最大的id
                  var omid = result.omid;//老的最大的
                  window.mid = b;
                  if (omid < b) {
                      window.ii = window.ii + 1;
                      window.ssss = 0;
                      var i = $('#divDetail li').size() + 1;

                      $("#qdtx").attr("src", result.avatar);
                      $("#qdnums").html(result.qdnums);
                      $("#qdname").html(result.nick_name);
                      $(".tuchu").addClass('view');

                      setTimeout(function() {
                          var item = '<li id="dh' + i + '" class="qiaodaosf" ><img class="qiaodaotx"  id="hd' + i + '" src="' + result.avatar + '"><p id="nc' + i + '" class="qiaodaoxm">' + result.nick_name + '</p><p id="qd' + i + '" class="qiaodaopm">' + result.qdnums + '</p></li>';
                          $('#divDetail').append(item);
                          var div = document.getElementById('divDetail');
                          document.getElementById('ddd').scrollTop = div.scrollHeight;
                      },1000);
                  } else {
                      window.ssss = window.ssss + 1;//1
                      /*if (window.ssss > 1) {
                      var s = $('#divDetail li').size() + 1;//2
                      var sjs = Math.floor(Math.random() * s);
                      if(sjs!=0){
                      $("#qdtx").attr("src", $("#hd" + sjs).attr("src"));
                      $("#qdnums").html($("#qd" + sjs).html());
                      $("#qdname").html($("#nc" + sjs).html());
                      $(".tuchu").addClass('view');
                      }
                      }*/
                  }
                  setTimeout("getjson(" + b + ")", 2000);

              },//success
              error:function () {
                  setTimeout("getjson(" + v + ")", 2000);
              }
          });
      }
  </script>
</div>
{template 'pc_footer'}